package com.community.zhihuishequ.net.entity;


/**
 * 响应数据
 */

public class AppResponse<T> {

    private boolean success;
    private String errcode;
    private String errmsg;
    private T data;

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public String getErrcode() {
        return errcode;
    }

    public void setErrcode(String errcode) {
        this.errcode = errcode;
    }

    public String getErrmsg() {
        return errmsg;
    }

    public void setErrmsg(String errmsg) {
        this.errmsg = errmsg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public boolean haveData() {
        return data != null;
    }

    public static String parseErrorCode(String errCode) {
        switch (errCode) {
            case "100":
                return "请求失败";
            case "150":
                return "登录超时, 请重新登录";
            case "300":
                return "传入参数错误";
            case "400":
                return "数据异常";
            case "500":
                return "服务器异常";
            default:
                return null;
        }

    }
}
